﻿// Original author contact info: Owen Emlen (owene_1998@yahoo.com)
// Note: other individuals may also have contributed to this code
// Project hosted on CodePlex.com as of 1/10/2009 at http://wpfimageviewer.codeplex.com
using System.Windows;
using System.Windows.Controls;
using ImageAppViewModels;

namespace WpfImageDuplicates
{
    /// <summary>
    /// Interaction logic for FilterViewWindow.xaml
    /// </summary>
    public partial class FilterViewWindow : UserControl
    {
        public static readonly DependencyProperty FilterCollectionCollectionViewModelProperty =
            DependencyProperty.Register("FilterCollectionCollectionViewModel", typeof(FilterCollectionCollectionViewModel), typeof(FilterViewWindow), new PropertyMetadata(null, OnFilterCollectionCollectionViewModelPropertyChanged));

        public FilterCollectionCollectionViewModel FilterCollectionCollectionViewModel
        {
            get { return (FilterCollectionCollectionViewModel)GetValue(FilterCollectionCollectionViewModelProperty); }
            set { SetValue(FilterCollectionCollectionViewModelProperty, value); }
        }

        private static void OnFilterCollectionCollectionViewModelPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            FilterViewWindow source = d as FilterViewWindow;
            source.UpdateFilterCollectionCollectionViewModel(e.NewValue as FilterCollectionCollectionViewModel);
        }

        private void UpdateFilterCollectionCollectionViewModel(FilterCollectionCollectionViewModel collections)
        {
            FilterCollectionCollectionViewModel = collections;

            // Let the UI bind to the view-model.
            this.DataContext = FilterCollectionCollectionViewModel;            
        }

        public FilterViewWindow()
        {
            InitializeComponent();
        }
    }
}
